<?php

namespace App\Http\Controllers\Home;

use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Foundation\Auth\Access\AuthorizesResources;
use DB;

class SuppliesController extends BaseController{
	public function supplies($keywords=""){

		$req=request();
        $list= DB::table('jtkj_suppliers')->get();
       if($_GET){
        
        $keywords=$req->keywords;
        $list=DB::table('jtkj_suppliers')
                ->where('g_name', 'like', $keywords.'%') //这一句里面不止content，而是title和content两个字段
                ->paginate(3);
        }
      return view('Home.supplies',['msg'=>$list,'keywords'=>$keywords]);
		
	}
	public function supplies_content($id){
		$req=request();
    	$list= DB::table('jtkj_suppliers')->where('g_id',$id)->first();
    	$lists= DB::table('jtkj_supplier_goods')->where('g_id',$id)->get();
    	return view('Home.supplies_content',['msg'=>$list],['ms'=>$lists]);
	}

	public function supplies_goods($id){
		$req=request();
		$list= DB::table('jtkj_supplier_goods')->where('g_id',$id)->get();
		$lists= DB::table('jtkj_suppliers')->where('g_id',$id)->first();
		return view('Home.supplies_goods',['msg'=>$list],['ms'=>$lists]);
	}

	public function supplies_active($id){

		$req=request();
		$list= DB::table('jtkj_favourable')->where('dian_id',$id)->get();
		$listt= DB::table('jtkj_supplier_goods')->where('g_id',$id)->first();
		return view('Home.supplies_active',['msg'=>$list],['ms'=>$listt]);
		
	}
	
	public function supplies_picture($id){
		$list= DB::table('jtkj_img')->where('g_id',$id)->get();
		$msg=DB::table('jtkj_suppliers')->where('g_id',$id)->first();
		return view('Home.supplies_picture',['msg'=>$list],['ms'=>$msg]);
	}

	public function supplies_tell($id){
		$list= DB::table('jtkj_suppliers')->where('g_id',$id)->first();
		return view('Home.supplies_tell',['msg'=>$list]);
	}

	public function supplies_active_detail($id){
		
		$req=request();
		$list= DB::table('jtkj_favourable')->where('goods_hd_id',$id)->get();
		$msg= DB::table('jtkj_favourable')->where('goods_hd_id',$id)->first();
		return view('Home.supplies_active_detail',['msg'=>$list],['row'=>$msg]);
	}
}